package com.dcbeida.model;

import com.dcbeida.utils.GenApiHashUrl;
import com.dcbeida.utils.JsonGet;

import dc.medicine.com.okhttplib.OkHttpUtils;
import dc.medicine.com.okhttplib.callback.AbsCallback;

/**
 * Created by hp on 2016/7/27.
 */
public class LoginModel  {

    private static LoginModel mLoginModel;
    private LoginModel(){

    }

    public static LoginModel newInstance() {
        if(mLoginModel==null){
            return new LoginModel();
        }else {
            return mLoginModel;
        }
    }

   public   void getDate(String username,String password,AbsCallback mAbsCallback){
       OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
               .paramsApp("service","login")
               .paramsApp("params",new JsonGet().putopt("username",username).putopt("password",password).tostring()).execute(mAbsCallback);
   }

    public void loginbysmscode(String mobile,String code,AbsCallback mAbsCallback){
        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service","loginbysmscode")
                .paramsApp("params",new JsonGet().putopt("mobile",mobile).putopt("code",code).tostring()).execute(mAbsCallback);
    }

    public void sendMsmCode(String accountofTel,AbsCallback mAbsCallback){
        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service","sendsmscode")
                .paramsApp("params",new JsonGet().putopt("mobile",accountofTel).tostring()).execute(mAbsCallback);
    }

    public void loginbyPassword(String mobile,String password,AbsCallback mAbsCallback){
        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service","loginbysmscode")
                .paramsApp("params",new JsonGet().putopt("mobile",mobile).putopt("password",password).tostring()).execute(mAbsCallback);
    }

    public  void getCancel(){
        OkHttpUtils.getInstance().cancelTag(this);
    }
}
